<?php
/**
 * Created by PhpStorm.
 * User: lzy
 * Date: 2018/11/8
 * Time: 15:56
 */

namespace App\Weixin\Controllers\Home;

use App\Base\Controllers\Controller;
use App\Weixin\Contracts\WithdrawInterface;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;


/**
 * 用户提现记录
 * Class WithdrawController
 * @package App\Weixin\Controllers\Home
 */
class WithdrawController extends Controller
{
    /**
     * 提现
     * @return WithdrawInterface
     */
    public function getWithdrawInterface()
    {
        return app()->make(WithdrawInterface::class);
    }


    public function add(Request $request)
    {

        $validator=Validator::make($request->all(), [
            'amount' => 'required|numeric',
            'account' => 'required',
        ],["amount.required"=>'金额必须有值',"account.required"=>'账号必须有值']);
        if ($validator->fails()) {
            $this->throwValidatorException($validator);
        }
        return $this->getWithdrawInterface()->addWithdrawLog($request->all());
    }

    /**
     * 获取数据列表
     * @param Request $request
     * @return mixed
     */
    public function getList(Request $request){
        $where=function($query) use ($request){
            $query->where("uid",AUID);
        };
        return  $this->getWithdrawInterface()->getList($where);
    }


}